package com.strategy;

public class Context {
    Strategy strategy;
    //构造函数，初始化时传入具体的策略对象
    public Context(Strategy strategy){
        this.strategy = strategy;
    }
    //根据具体的策略对象，调用其算法的方法
    public void ContextInterface(){
        strategy.AlgorithmInterface();
    }

    public static void main(String[] args) {
        Context context;
        context = new Context(new ConcreteStrategyA());
        context.ContextInterface();

        context = new Context(new ConcreteStrategyB());
        context.ContextInterface();
    }
}
